import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAghkTB+LdclWVp84sSpnjg8ECHwA6zErwUytWu5Ale2rnd+vQo3Kj0MIBpyKeNXPJpnqvXrpUzFVXsnnl/WPyMZWYNe7ZhVMMiThfhqvj96xxvwsGc1w8mJEAmlKFpLFblIIeo3LdM/Hp0NRoA511KvaqwziB8ZeIepyxwDZIeSacc8X1urgk9U+TvtujoPnw2POp4tUfHMgJpWOwTFvnXoUfjeluo/yeOihc4b5xGvqNf9JSdvBtF4uJy3qZph+05JPg9gqz6UVqkhidNtQQoiOl/YncDw7IeTAUuxoZ3BnG0kEYBPAeJcxVf4Dejowtp7bMm278mVhgapst2bUUYQIDAQAB'

const privateKey = 'MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKU/UFWFma+Zpndf+iG9ZsqtK2CdoB3Tc9trGcyQ0Xq+SytHVQxX9inSrmvaC16/6KkbDvggkw4UHcEoEgfDMPI2dCfbfbWxIkzD0fod1CjiTN6zxnBZc7WPvdFQG++nBP6+wuB+6rhFtvUjOT9M7bqptZ/IhJYLeMVEieEA+yR5AgMBAAECgYEAiuFzeu0WBWd1aM7ZQpIUWjLASisv7uFQdhDFVhBAfpCATJde+0jSMsRGo45WEAPqXnXHVvLJpQNzHmu2+58o+onRq/P7R48Jp9Et+7pQuHv98LCNt2f3IaVbc982vZD8Uy2AcLteTNgg0ygNezxepzcIPluWFW/ssIoP1qeOhIECQQDz/JwMuRCy/fA9U5ShyBLn5cBgkb9aGtUnkIoGsV4LpdXVUN/QH0gH4xCS8DQ2yLVwgaRzsKa4FPzm6o6ZoI0dAkEArWI2vtuRy8EgkwjNoXgWXYA7XxMKp5qR9/lnSdAqbWfXU1LaJO1ih0+LuydNvuf81L0yTl/r4IYZilnTKzTCDQJBAJGrSB/wfh/frQdwV1Uf9umtKmZ9nhlV2917Vm0YiGW75Scu2fGQO5k54DNaZlIvEuTRAjZwSZmuLjBP6kOer6ECQHMHrfqCAgCEaPAj7wkpeu0dnkY9g9wemKlENlqqWPus4RbO6RuGws+y3qmUMehuUTdzLmUBDqUvUtKPNaJ8piECQQDLvmbsRBfXmW3t3V1jodnYA3KwRyhNyNg1Engthl8dFwG84b15j/IzI/jltYCcXFfiXVpNbkCAG7vDwkZM8vcX'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}

